Skip to content

fix: cross-platform Node wrapper for ssh-manager CLI (#22)#23

Merged
bvisible merged 1 commit intomainfrom
fix/windows-cli-wrapper
May 2, 2026
Merged

fix: cross-platform Node wrapper for ssh-manager CLI (#22)#23
bvisible merged 1 commit intomainfrom
fix/windows-cli-wrapper

Conversation

@bvisible
Copy link
Copy Markdown
Owner

@bvisible bvisible commented Apr 9, 2026

Summary

Fixes #22 — on native Windows shells (PowerShell, cmd) the ssh-manager CLI failed immediately after a global install because npm cannot wrap a Bash-shebang script properly: the generated .ps1/.cmd shim tried to run /bin/bash.exe, and even when a bash was on PATH, Windows paths (C:\...) were not translated into POSIX form so the script could not be located.

This PR replaces the ssh-manager bin entry with a small cross-platform Node wrapper that delegates to the existing Bash CLI. No Bash code was touched — the 2500-line CLI keeps running unchanged on Unix.

What the wrapper does

  • On Unix — forwards argv to cli/ssh-manager via bash (zero behavior change).
  • On Windows, probes in order:
    1. Git Bash — looks in %ProgramFiles%\Git\bin\bash.exe, %ProgramFiles(x86)%, %LOCALAPPDATA%\Programs\Git\bin\bash.exe, and two hard-coded defaults. Paths are converted to MSYS form (C:\foo/c/foo) before invocation.
    2. WSL — detected via wsl.exe --status; script path is converted to /mnt/c/... and launched via wsl.exe bash ....
    3. bash on PATH — last resort (custom MSYS2 installs, etc.).
  • If none of the three are available, prints an actionable message with links to Git for Windows and instructions for wsl --install, and exits 1.

The MCP server itself (mcp-ssh-managersrc/index.js) is untouched and continues to work on Windows with zero dependencies on Bash.

Files changed

  • cli/ssh-manager.js (new) — Node wrapper, ESM, no external deps.
  • package.jsonbin.ssh-manager now points at cli/ssh-manager.js instead of cli/ssh-manager.

How to test

Unix (should behave exactly as before)

npm install
node cli/ssh-manager.js --version
node cli/ssh-manager.js --help
node cli/ssh-manager.js server list

Windows (PowerShell / cmd)

# From a local clone
npm install -g .

# Then in a fresh shell
ssh-manager --version
ssh-manager --help
ssh-manager server add

Expected:

  • With Git for Windows installed → commands run transparently via Git Bash.
  • With WSL installed (and no Git Bash) → commands run via wsl.exe bash.
  • With neither → a clear error message explaining how to install Git for Windows or WSL.

Test plan

  • node --check cli/ssh-manager.js passes
  • ./scripts/validate.sh passes
  • node cli/ssh-manager.js --version on macOS forwards correctly to the Bash script
  • node cli/ssh-manager.js --help on macOS forwards correctly (colors, subcommand list preserved)
  • Manual verification on Windows 11 + Git for Windows
  • Manual verification on Windows 11 + WSL only
  • Manual verification on Windows 11 with neither (expect actionable error)

The last three items require a Windows machine — @Eleef opened the original issue and offered to help test, so I'd like to ask them to confirm on their setup before we merge.

Closes #22

The ssh-manager bin entry used to point directly at a Bash script, which
npm cannot wrap on native Windows shells — the generated .ps1/.cmd shim
tries to invoke /bin/bash.exe, and even when a bash is available, Windows
paths are not translated into POSIX form so the script cannot be found.

Replace the bin entry with a small Node wrapper that:

- On Unix, simply forwards argv to the existing Bash script via `bash`.
- On Windows, probes for Git Bash (Program Files / LocalAppData), then
  WSL, then `bash` on PATH. Windows paths are converted to MSYS
  (/c/...) or WSL (/mnt/c/...) form as appropriate before invocation.
- Prints an actionable message pointing at Git for Windows or WSL when
  no compatible Bash interpreter can be located.

The underlying Bash CLI is untouched, so there is no regression for
existing Unix users. Closes #22.
@bvisible bvisible merged commit 8e5f5b5 into main May 2, 2026
@bvisible bvisible deleted the fix/windows-cli-wrapper branch May 2, 2026 16:55
bvisible added a commit that referenced this pull request May 2, 2026
…ync` (#22) (#26)

Reported by @Eleef while validating the Windows wrapper fix in #23. After
the wrapper started working, `server add` (and every other command) still
exited at startup with:

    Missing required dependencies: rsync

rsync was listed alongside `ssh` in the global `check_dependencies`
gate, but it is only used by `cmd_sync`. Git for Windows (and most
out-of-the-box MSYS2/Cygwin setups) does not ship rsync, so this gate
prevented the CLI from running at all on a fresh Windows install — even
for users who never intend to call `sync`.

Changes:
- `cli/lib/config.sh`: drop rsync from the required list, add it to the
  optional warning, and introduce a small `require_command` helper that
  prints actionable install hints (macOS/Debian/Windows).
- `cli/ssh-manager`: `cmd_sync` calls `require_command rsync` so the
  failure happens at the point of use with a clear message instead of
  blocking startup.
- `cli/install.sh`: same reclassification in the installer's dependency
  probe so users see a yellow warning, not a red blocking error.

Verified locally on macOS by stripping rsync from PATH:
  - `--version`, `--help`, `server list` → exit 0 (warn-only)
  - `sync push ...`                       → exit 1 with install hints

Closes the residual rsync issue surfaced in #22; complements #23.
bvisible added a commit that referenced this pull request May 2, 2026
Aggregates four bug fixes (#22 wrapper, #22 rsync, #25, #28) and one
feature (#24 ProxyCommand) merged today via PRs #23, #26, #27, #29, #24.

See CHANGELOG.md for full details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows global install: ssh-manager fails due /bin/bash shim/path handling

1 participant